#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "Buzzer.h"
#include "LightSensor.h"
#include "LED.h"

int main(void)
{
	Led_Init(RCC_APB2Periph_GPIOA, GPIOA, GPIO_Pin_2 | GPIO_Pin_4);
	Buzzer_Init(RCC_APB2Periph_GPIOB, GPIOB, GPIO_Pin_12);
	LightSensor_Init(RCC_APB2Periph_GPIOB, GPIOB, GPIO_Pin_15);
	
	while(1)
	{
		if(LightSensor_Ctrl_Buzzer(GPIOB, GPIO_Pin_15) == ON_ALARM)
		{
			Led_Set(ON, GPIOA, GPIO_Pin_2 | GPIO_Pin_4);
			Buzzer_Set(ON_ALARM, GPIOB, GPIO_Pin_12);
		}
		else
		{
			Led_Set(OFF, GPIOA ,GPIO_Pin_2 | GPIO_Pin_4);
			Buzzer_Set(OFF_ALARM, GPIOB, GPIO_Pin_12);
		}
	}
}
